package com.xuelang.pipeline.client.pipeline;

import com.xuelang.pipeline.client.common.constant.DictDTO;
import com.xuelang.pipeline.client.common.request.PageParam;
import com.xuelang.pipeline.client.common.result.ApiResult;
import com.xuelang.pipeline.client.common.result.PageRecord;
import com.xuelang.pipeline.client.pipeline.dto.DeploymentUnitDTO;
import com.xuelang.pipeline.client.pipeline.dto.DeploymentUnitQuery;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>部署单服务API接口定义</p>
 *
 * @author : yixin.lys
 * @date : 2024-06-26 11:32
 **/
public interface IDeploymentUnitService {

    /**
     * 根据流水线编码分页获取部署单
     *
     * @param query
     * @return
     */
    @PostMapping(value = "/page", produces = "application/json;charset=utf-8")
    ApiResult<PageRecord<DeploymentUnitDTO>> page(@RequestBody PageParam<DeploymentUnitQuery> query);

    /**
     * 通过流水线实例编码查询部署单详情
     *
     * @param pipelineInstanceCode
     * @return
     */
    @GetMapping(value = "/queryByPipelineInstanceCode", produces = "application/json;charset=utf-8")
    ApiResult<DeploymentUnitDTO> queryByPipelineInstanceCode(@RequestParam("pipelineInstanceCode") String pipelineInstanceCode);

    /**
     * 部署单回滚
     *
     * @param id
     * @return
     */
    @GetMapping(value = "/rollback/{id}", produces = "application/json;charset=utf-8")
    ApiResult<Boolean> rollback(@PathVariable("id") String id);

    /**
     * 部署单继续
     *
     * @param id
     * @return
     */
    @GetMapping(value = "/continue/{id}", produces = "application/json;charset=utf-8")
    ApiResult<Boolean> continueDeployment(@PathVariable("id") String id);

    /**
     * 部署进度字典
     * @return
     */
    @PostMapping(value = "/process/status", produces = "application/json;charset=utf-8")
    ApiResult<List<DictDTO>> deploymentProcessStatus();
}
